package org.jeecg.modules.health_records.health_spine.service.impl;

import org.jeecg.modules.health_records.health_spine.entity.HealthSpineIndexInfo;
import org.jeecg.modules.health_records.health_spine.mapper.HealthSpineIndexInfoMapper;
import org.jeecg.modules.health_records.health_spine.service.IHealthSpineIndexInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 现病史-体格检查-脊柱特殊试验
 * @Author: jeecg-boot
 * @Date:   2025-06-25
 * @Version: V1.0
 */
@Service
public class HealthSpineIndexInfoServiceImpl extends ServiceImpl<HealthSpineIndexInfoMapper, HealthSpineIndexInfo> implements IHealthSpineIndexInfoService {
    @Autowired
    private HealthSpineIndexInfoMapper  healthSpineIndexInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpineIndexInfo> queryByRecordId(HealthSpineIndexInfo healthSpineIndexInfo) {
        return healthSpineIndexInfoMapper.queryByRecordId(Long.valueOf(healthSpineIndexInfo.getRecordid()),healthSpineIndexInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpineIndexInfo> queryElecRecord(HealthSpineIndexInfo healthSpineIndexInfo) {
        return healthSpineIndexInfoMapper.queryElecRecord(Long.valueOf(healthSpineIndexInfo.getRecordid()),healthSpineIndexInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpineIndexInfo> newQueryElecRecord(HealthSpineIndexInfo healthSpineIndexInfo) {
        return healthSpineIndexInfoMapper.newQueryElecRecord(Long.valueOf(healthSpineIndexInfo.getRecordid()),healthSpineIndexInfo.getSeeId(),healthSpineIndexInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthSpineIndexInfo> newQueryPastRecord(HealthSpineIndexInfo healthSpineIndexInfo) {
        return healthSpineIndexInfoMapper.newQueryPastRecord(Long.valueOf(healthSpineIndexInfo.getRecordid()),healthSpineIndexInfo.getSeeId(),healthSpineIndexInfo.getIdNumber());

    }
}
